
fn binding_normal() {
    fn age() -> u32 {
        15
    }

    println!("Tell me what type of person you are");
    match age() {
        0 => println!("i haven't celebrated my first birthday yet"),
        // could `match` 1..12 directly but when what age
        // would the child be? instead, bind to `n` for the
        // sequence of 1..12. now the age canbe reported.
        n @ 1..=12 => println!("I'm a child of age {:?}", n),
        // if we remove `=`, compiler will report an error: exclusive range pattern syntax is experimental
        n@13..=19 => println!("I'm a teen of age {:?}", n),
        n => println!("I'm an adult of age {:?}", n),
    }
}

fn binding_enums() {
    fn some_number() -> Option<u32> {
        Some(42)
    }
    
    match some_number() {
        // Got `Some` variant, match if its value, bound to `n`,
        // is equal to 42.
        Some(n @ 42) => println!("The Answer: {}!", n),
        // Match any other number.
        Some(n)      => println!("Not interesting... {}", n),
        // Match anything else (`None` variant).
        _            => (),
    }
}

fn main() {
    binding_normal();
    binding_enums();
}